<?php
declare (strict_types = 1);
namespace app\school\logic\school\admin;

use app\common\exception\LogicException;
use app\school\model\school\admin\SchoolLog as SchoolLogModel;

/**
 * 机构记录逻辑层
 */
class SchoolLog extends SchoolLogModel
{

    /**
     * 生成日志
     * Author   Martinsun<syh@sunyonghong.com>
     * Date 2020-06-04
     * @param    int                            $mhm_id        [description]
     * @param    string                         $info          [description]
     * @param    int|integer                    $user_id       [description]
     * @return   [type]                                        [description]
     */
    public function writeLog(int $mhm_id, string $info, int $user_id = 0)
    {
        $this->mhm_id        = $mhm_id;
        $this->info          = $info;
        $this->user_id       = $user_id;

        if (!$this->save()) {
            throw new LogicException('日志生成失败');
        }

        return $this;
    }
}
